package com.kevin.state;

/**
 * 环境类（上下文）
 *
 * @author kevin
 * @date 2025/8/22
 */
public class Context {

    private State state;

    /**
     * 类初始化时，定义一个默认状态
     */
    public Context()
    {
        this.state = new ConcreteState1();
    }

    public State getState() {
        return state;
    }

    /**
     * 设置新状态
     */
    public void setState(State state)
    {
        this.state = state;
    }

    /**
     * 对请求做处理
     */
    public void handle()
    {
        state.handle(this);
    }
}
